import React, { Component } from 'react'
import Header from '../componets/header'
import Body from '../componets/body'
import axios from "../utils/axios"
 class Tabf extends Component {
  state = {
      data:[]
  }
  componentDidMount(){
      axios.get("/tablist").then(res=>{
          console.log(res,222222);
          this.setState({
              data:res.data
          },()=>console.log(this.state.data,"1111"))
      })
  }
  delfn = (data)=>{
        console.log(data,"zichuanc")
        this.state.data.splice(data,1) // splice 函数返回得是被删除得那一项，我们需要得是已经删除过得原数组
        // console.log(arr,1111111111)
        this.setState({
            data:this.state.data
        })
  }
  render() {
    let {data} = this.state
    return (
      <div>
          {
              data&&data.length?  <Header send={data} delFn={this.delfn}>
                 {
                     ()=><div>222</div>
                     
                 }
              </Header> :"暂无数据"
          }
         {
              data&&data.length? <Body send={data}></Body> :"暂无数据"
         }
         
      </div>
    )
  }
}

export default Tabf